package c.a.a.d0;

import android.graphics.PointF;
import android.view.animation.Interpolator;
import android.view.animation.LinearInterpolator;
import android.view.animation.PathInterpolator;
import b.f.i;
import c.a.a.d0.h0.c;
import c.a.a.d0.h0.c.a;
import c.a.a.e0.g;
import c.a.a.f;
import c.j.a.d.b.e.h;
import java.io.IOException;
import java.lang.ref.WeakReference;

/* compiled from: KeyframeParser */
public class p {
    public static final Interpolator a = new LinearInterpolator();
    public static i<WeakReference<Interpolator>> b;
    public static a c = a.a("t", "s", "e", "o", c.j.a.d.a.i.j, h.q, "to", "ti");

    public static <T> c.a.a.f0.a<T> a(c cVar, f fVar, float f, g0<T> g0Var, boolean z) throws IOException {
        c cVar2 = cVar;
        float f2 = f;
        g0<T> g0Var2 = g0Var;
        if (!z) {
            return new c.a.a.f0.a(g0Var2.a(cVar2, f2));
        }
        Object obj;
        Class cls = p.class;
        cVar.o();
        Interpolator interpolator = null;
        int i = 1;
        PointF pointF = null;
        PointF pointF2 = pointF;
        Object obj2 = pointF2;
        Object obj3 = obj2;
        PointF pointF3 = obj3;
        PointF pointF4 = pointF3;
        Object obj4 = null;
        float f3 = 0.0f;
        while (cVar.t()) {
            switch (cVar2.w0(c)) {
                case 0:
                    f3 = (float) cVar.w();
                    break;
                case 1:
                    obj3 = g0Var2.a(cVar2, f2);
                    continue;
                case 2:
                    obj2 = g0Var2.a(cVar2, f2);
                    continue;
                case 3:
                    pointF = o.b(cVar2, f2);
                    continue;
                case 4:
                    pointF2 = o.b(cVar2, f2);
                    continue;
                case 5:
                    if (cVar.h0() != i) {
                        obj4 = null;
                        break;
                    }
                    obj4 = 1;
                    continue;
                case 6:
                    pointF4 = o.b(cVar2, f2);
                    continue;
                case 7:
                    pointF3 = o.b(cVar2, f2);
                    continue;
                default:
                    cVar.y0();
                    break;
            }
            i = 1;
        }
        cVar.r();
        if (obj4 != null) {
            interpolator = a;
            obj = obj3;
        } else {
            if (pointF == null || pointF2 == null) {
                interpolator = a;
            } else {
                WeakReference weakReference;
                float f4 = -f2;
                pointF.x = c.a.a.e0.f.b(pointF.x, f4, f2);
                pointF.y = c.a.a.e0.f.b(pointF.y, -100.0f, 100.0f);
                pointF2.x = c.a.a.e0.f.b(pointF2.x, f4, f2);
                float b = c.a.a.e0.f.b(pointF2.y, -100.0f, 100.0f);
                pointF2.y = b;
                f4 = pointF.x;
                float f5 = pointF.y;
                float f6 = pointF2.x;
                ThreadLocal threadLocal = g.a;
                int i2 = f4 != 0.0f ? (int) (((float) 527) * f4) : 17;
                if (f5 != 0.0f) {
                    i2 = (int) (((float) (i2 * 31)) * f5);
                }
                if (f6 != 0.0f) {
                    i2 = (int) (((float) (i2 * 31)) * f6);
                }
                if (b != 0.0f) {
                    i2 = (int) (((float) (i2 * 31)) * b);
                }
                synchronized (cls) {
                    if (b == null) {
                        b = new i(10);
                    }
                    weakReference = (WeakReference) b.e(i2, null);
                }
                if (weakReference != null) {
                    interpolator = (Interpolator) weakReference.get();
                }
                if (weakReference == null || r4 == null) {
                    PathInterpolator pathInterpolator;
                    pointF.x /= f2;
                    pointF.y /= f2;
                    b = pointF2.x / f2;
                    pointF2.x = b;
                    float f7 = pointF2.y / f2;
                    pointF2.y = f7;
                    try {
                        pathInterpolator = new PathInterpolator(pointF.x, pointF.y, b, f7);
                    } catch (IllegalArgumentException e) {
                        if (e.getMessage().equals("The Path cannot loop back on itself.")) {
                            pathInterpolator = new PathInterpolator(Math.min(pointF.x, 1.0f), pointF.y, Math.max(pointF2.x, 0.0f), pointF2.y);
                        } else {
                            interpolator = new LinearInterpolator();
                        }
                    }
                    interpolator = pathInterpolator;
                    try {
                        weakReference = new WeakReference(interpolator);
                        synchronized (cls) {
                            b.g(i2, weakReference);
                        }
                    } catch (ArrayIndexOutOfBoundsException unused) {
                    }
                }
            }
            obj = obj2;
        }
        PointF pointF5 = pointF3;
        PointF pointF6 = pointF4;
        c.a.a.f0.a aVar = new c.a.a.f0.a(fVar, obj3, obj, interpolator, f3, null);
        aVar.m = pointF6;
        aVar.n = pointF5;
        return aVar;
    }
}
